package reflect;

import java.lang.reflect.Constructor;

public class Test {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Student");
        Constructor c = cls.getConstructor(String.class, int.class,char.class);
        Object obj = c.newInstance("李四", 20, '男');
        System.out.println(obj);

        Constructor c1 = cls.getConstructor();
        Object obj1 = c1.newInstance();
        System.out.println(obj1);

        Constructor c2 = cls.getConstructor(String.class, int.class);
        Object obj2 = c2.newInstance("王五", 22);
        System.out.println(obj2);

        Constructor c3 = cls.getConstructor(String.class);
        Object obj3 = c3.newInstance("赵六");
        System.out.println(obj3);



    }
}
